package com.comet.mapper;

import com.comet.domain.Course;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface CourseMapper {

    @Select("select * from t_course where id = #{courseId}")
    Course findById(int id);

    @Insert("insert into t_course(id,title,summary,cover_img,price,create_time,point) values(#{id},#{title},#{summary},#{cover_img},#{price},#{create_time},#{point})")
    int saveCourse(Course course);

    @Update("update t_stock set stock = (stock - #{num}) where sku_id = #{skuId}")
    int deductStockBySkuId(@Param("skuId") Integer skuId, @Param("num") Integer num);

    @Insert("insert into t_course(course_name,course_desc,price,status,logo_url,category,remark) values(#{courseName},#{courseDesc},#{price},#{status},#{logoUrl},#{category},#{remark})")
    Course addCourse(Course course);

}
